var range = 200;             //距下边界长度/单位px
var elemt = 500;           //插入元素高度/单位px
var maxnum = 'no';            //设置加载最多次数
var num = 2;
var totalheight = 0;
var PAGESIZE= 15;
var type= 0; /*0是充值，1是提现*/
var enable = 1;
$(document).ready(function(){

        var all_list = $("#all_list");                     //主体元素  
        $(window).scroll(function(){  
            var srollPos = $(window).scrollTop();    //滚动条距顶部距离(页面超出窗口的高度)
              
            //console.log("滚动条到顶部的垂直高度: "+$(document).scrollTop());  
            //console.log("页面的文档高度 ："+$(document).height());  
            //console.log('浏览器的高度：'+$(window).height());  
              
            totalheight = parseFloat($(window).height()) + parseFloat(srollPos);
            if(($(document).height()-range) <= totalheight  && num != maxnum) {
				addNextPage();
            }
        });
});
function addNextPage(){
    if( enable == 1 )
    {
        $(".more-btn").removeClass("hide");
        load_water(num,PAGESIZE,type,0);
        num++;
        enable = 0;
    }
}

/*1,15,0,1 充值*/
function load_water(num,PAGESIZE,listtype,isnull){
        type = listtype;
	    $.ajax({
        type : "POST",
        url : "/Wap/user/bank_water_show",
        data : "page=" + num + "&pagesize=" + PAGESIZE + "&type="+listtype,
        datatype : 'JSON',
        async : true,
        success : function(response) {
            enable = 1;
			if(response=='' || response == null ){

				return false;
			}
			if(isnull==1){
                $("#list0").empty();
                $("#list1").empty();
            }

            if( listtype == 1 ) {
                /*提现*/
                $.each(response, function (key, value) {

                    $("#list1").append('<dt><span>' + value.create_time + '</span><span>' + value.amount + '元</span><span>'+value.auth_state+'</span></dt>');
                });
            }else if( listtype == 0 )
            {
                $.each(response, function (key, value) {
                    $("#list0").append('<dt><span>' + value.create_time + '</span><span>' + value.amount + '元</span><span>'+value.auth_state+'</span></dt>');
                });
            }

        },
        error : function(data) {
            enable = 1;
        },
        //  "json");
    });
}